﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OrderHistory.aspx.cs" Inherits="EarringsRecommendationWeb.OrderHistory" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Order History</title>
    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.css" rel="stylesheet">
    <link href="css/bootstrap-theme.css" rel="stylesheet" />

    <script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.js"></script>   
    <script type="text/javascript" src="js/bootbox.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#form-nav-bar').load('navbar.html');
            $.getScript("js/Login.js", function () { });
        });
    </script>
    <script src="js/toast.js" type="text/javascript"></script>
    <script src="js/formatmoney.js"></script>
    
</head>
<body>
    
    <div class="alert alert-success" role="alert" style="display:none; z-index: 1000; position: absolute; left:0px; top: 50px;">
      <span>populate alert</span>
    </div>
    <!-- Navigation -->
    <nav id="form-nav-bar" class="navbar navbar-inverse navbar-static-top" role="navigation">        
        <!-- /.container -->
    </nav>
    <form runat="server" id="checkoutOrder">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        </telerik:RadAjaxManager>
    <!-- Page Content -->
    <div class="container">
        <telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="-1" DataSourceID="SqlDataSource1" GridLines="Both" AutoGenerateColumns="False" AllowPaging="True" PageSize="10">
            <MasterTableView DataSourceID="SqlDataSource1" DataKeyNames="Reserve_Id">
                <DetailTables>
                    <telerik:GridTableView DataKeyNames="Reserve_Id" 
                        DataSourceID="SqlDataSource2" Width="100%" runat="server">
                        <ParentTableRelation>
                            <telerik:GridRelationFields DetailKeyField="Reserve_Id" MasterKeyField="Reserve_Id"></telerik:GridRelationFields>
                        </ParentTableRelation>                       
                                                   
                        <Columns>
                            <telerik:GridBoundColumn SortExpression="Er_Code" HeaderText="Code" HeaderButtonType="TextButton"
                                DataField="Er_Code" UniqueName="Er_Code">
                                <HeaderStyle Width="100px" />
<ColumnValidationSettings>
<ModelErrorMessage Text=""></ModelErrorMessage>
</ColumnValidationSettings>
                            </telerik:GridBoundColumn>
                            <telerik:GridImageColumn DataImageUrlFields="imgPath" ImageWidth="100px" ImageHeight="100px">
                                <HeaderStyle Width="120px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </telerik:GridImageColumn>
                            <telerik:GridBoundColumn SortExpression="Quatity" HeaderText="Quantity" HeaderButtonType="TextButton"
                                DataField="Quatity" UniqueName="Quatity">
                                <HeaderStyle Width="80px" HorizontalAlign="Center" />
                                <ItemStyle HorizontalAlign="Center" />
<ColumnValidationSettings>
<ModelErrorMessage Text=""></ModelErrorMessage>
</ColumnValidationSettings>
                            </telerik:GridBoundColumn>                                   
                        </Columns>
                        <SortExpressions>
                            <telerik:GridSortExpression FieldName="Quatity" SortOrder="Descending"></telerik:GridSortExpression>
                        </SortExpressions>                        
                                              
                    </telerik:GridTableView>
                </DetailTables>

            <Columns>
                <telerik:GridBoundColumn SortExpression="Reserve_Id" HeaderText="เลขที่จอง" HeaderButtonType="TextButton"
                    DataField="Reserve_Id" UniqueName="Reserve_Id">               
<ColumnValidationSettings>
<ModelErrorMessage Text=""></ModelErrorMessage>
</ColumnValidationSettings>
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn SortExpression="Reserve_date" HeaderText="วันที่จอง" HeaderButtonType="TextButton"
                    DataField="Reserve_date" UniqueName="Reserve_date" DataFormatString="{0:d}">
<ColumnValidationSettings>
<ModelErrorMessage Text=""></ModelErrorMessage>
</ColumnValidationSettings>
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn SortExpression="TotalAmount" HeaderText="จำนวนเงิน" HeaderButtonType="TextButton"
                    DataField="TotalAmount" UniqueName="TotalAmount" DataFormatString="{0:N2}">
<ColumnValidationSettings>
<ModelErrorMessage Text=""></ModelErrorMessage>
</ColumnValidationSettings>
                    <ItemStyle HorizontalAlign="Right" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn SortExpression="Receive_Date" HeaderText="วันที่รับ" HeaderButtonType="TextButton"
                    DataField="Receive_Date" UniqueName="Receive_Date" DataFormatString="{0:d}">
<ColumnValidationSettings>
<ModelErrorMessage Text=""></ModelErrorMessage>
</ColumnValidationSettings>
                </telerik:GridBoundColumn>
            </Columns>

            </MasterTableView>            

            <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
        </telerik:RadGrid>
    </div>
    <!-- /.container -->
    <div class="container">
        <hr>
        <!-- Footer -->
        <footer>
            <div class="row">
                <div class="col-lg-12">
                    <p>
                        Copyright &copy; Your Website 2015
                    </p>
                </div>
            </div>
        </footer>
    </div>
    <!-- /.container -->
    <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:ConnStringDb %>"
        ProviderName="System.Data.SqlClient" 
        SelectCommand="select Reserve_Id, Email, Reserve_date, Reserve_Status, TotalAmount, Receive_Date 
                        from dbo.Reserve 
                        where email = @email
                        order by Reserve_Date asc, Reserve_Id asc"
        runat="server">
        <SelectParameters>
            <asp:SessionParameter DefaultValue="" Name="email" SessionField="MemberEmail" Type="Object" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:ConnStringDb %>"
        ProviderName="System.Data.SqlClient" 
        SelectCommand="select r.Reserve_Detail_Id, r.Reserve_Id, r.Er_Code, r.Quatity,
'Data/Earrings/' + erconf.config_name + '/' + e.er_image_front AS [imgPath]
from dbo.ReserveDetail r inner join earrings e on r.er_code = e.er_code
INNER JOIN earringsconfig erconf on e.er_style = erconf.config_id
where Reserve_Id = @Reserve_Id "
        runat="server">
        <SelectParameters>
            <asp:SessionParameter Name="Reserve_Id" SessionField="Reserve_Id" Type="Int32"></asp:SessionParameter>
        </SelectParameters>
    </asp:SqlDataSource>
    </form>

</body>
</html>

